<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
	{$LOAD_STYLE.top|raw}
</head>
<body>
<form class="layui-form" action="">
    <div class="mainBox">
        <div class="main-container">
			<div class="layui-tab layui-tab-brief" lay-filter="TabBrief">
			    <ul class="layui-tab-title">
			        <li class="layui-this">基本信息</li>
					<li>供货信息</li>
					<li>其他参数</li>
			    </ul>
			    <div class="layui-tab-content">
					<div class="layui-tab-item layui-show">
						
						<div class="layui-form-item2 layui-col-md6">
							<label class="layui-form-label">编号</label>
							<div class="layui-input-block">
								<input type="hidden" name="old_number" value="{$model.number??''}">
							  <input type="text" name="number" value="{$model.number??''}" placeholder="请输入编号" class="layui-input"  verify="must">
							</div>
						</div>
						
						<div class="layui-form-item2 layui-col-md6">
							<label class="layui-form-label">面料分类</label>
							<div class="layui-input-block">
							  <select name="tid" lay-verify="required" verify="must"'>
								<option value=""></option>
								{volist name="type_list" id="v"}
								{if !$action_up}
								<option value="{$v.id}">{$v.name}</option>
								{elseif $v.id == $model.tid}
								<option value="{$v.id}" selected="selected">{$v.name}</option>
								{else/}
								<option value="{$v.id}">{$v.name}</option>
								{/if}
								{/volist}
							  </select>
							</div>
						</div>
						
						<div class="layui-form-item">
							<label class="layui-form-label">品名</label>
							<div class="layui-input-block">
							  <input type="text" name="title" value="{$model.title??''}" placeholder="请输入品名" class="layui-input"  verify="must">
							</div>
						</div>
						
						<div class="layui-form-item2 layui-col-md3">
							<label class="layui-form-label">幅宽</label>
							<div class="layui-input-block">
								<div class="input-group layui-col-md12">
							    <input type="text" name="breadth" value="{$model.breadth??''}" placeholder="请输入幅宽" class="layui-input"  verify="must">
								<span class="input-group-addon">cm</span>
								</div>
							</div>
						</div>
						
						<div class="layui-form-item2 layui-col-md3">
							<label class="layui-form-label">克重</label>
							<div class="layui-input-block">
							    <div class="input-group layui-col-md12">
							    <input type="text" name="square" value="{$model.square??''}" placeholder="请输入克重" class="layui-input"  verify="must">
								<span class="input-group-addon">g</span>
								</div>
							</div>
						</div>
						
						<div class="layui-form-item2 layui-col-md6">
							<label class="layui-form-label">幅宽规格</label>
							<div class="layui-input-block">
								{php}if(!$action_up) $model["side_type"]='实用';{/php}
								{volist name="options.side_type" id="v"}
								{if $v == $model.side_type}
								<input type="radio" name="side_type" title="{$v}" value="{$v}" checked>
								{else/}
								<input type="radio" name="side_type" title="{$v}" value="{$v}">
								{/if}
								{/volist}
							</div>
						</div>
						
						<div class="layui-form-item2 layui-col-md3">
							<label class="layui-form-label">纸管重量</label>
							<div class="layui-input-block">
							  <div class="input-group layui-col-md12">
							  <input type="text" name="tube" value="{$model.tube??''}" placeholder="请输入纸管重量" class="layui-input"  verify="must">
							  <span class="input-group-addon">kg</span>
							  </div>
							</div>
						</div>
						
						<div class="layui-form-item2 layui-col-md3">
							<label class="layui-form-label">空差重量</label>
							<div class="layui-input-block">
							  <div class="input-group layui-col-md12">
							  <input type="text" name="emptykg" value="{$model.emptykg??''}" placeholder="请输入空差重量" class="layui-input"  verify="must">
							  <span class="input-group-addon">kg</span>
							  </div>
							</div>
						</div>
						
						<div class="layui-form-item2 layui-col-md3">
							<label class="layui-form-label">1公斤出</label>
							<div class="layui-input-block">
								<div class="input-group layui-col-md12">
								<input type="text" name="kgm" value="{$model.kgm??'0'}" placeholder="一公斤出的米数" class="layui-input"  verify="must">
								<span class="input-group-addon">米</span>
								</div>
							</div>
						</div>
						
						<div class="layui-form-item2 layui-col-md3">
							<label class="layui-form-label">1公斤出</label>
							<div class="layui-input-block">
								<div class="input-group layui-col-md12">
								<input type="text" name="kgy" value="{$model.kgy??'0'}" placeholder="一公斤出的码数" class="layui-input"  verify="must">
								<span class="input-group-addon">码</span>
								</div>
							</div>
						</div>
						
						<div class="layui-form-item">
							<label class="layui-form-label">成分</label>
							<div class="layui-input-block">
								<input type="text" name="component" value="{$model.component??''}" placeholder="请输入成分" class="layui-input">
							</div>
						</div>
						
						<div class="layui-form-item">
							<label class="layui-form-label"></label>
							<div class="layui-input-block">
								{foreach $component as $item}
								<button type="reset" class="layui-btn layui-btn-primary layui-btn-sm" component="{$item.val}">{$item.name}</button>
								{/foreach}
							</div>
						</div>
						
						<div class="layui-form-item2 layui-col-md5">
							<label class="layui-form-label">1米价格</label>
							<div class="layui-input-block">
							  <div class="input-group layui-col-md12">
							  <input type="text" name="price4" value="{$model.price4??''}" placeholder="请输入1米价格" class="layui-input"  verify="must">
							  <span class="input-group-addon">元</span>
							  </div>
							</div>
						</div>
						
						<div class="layui-form-item2 layui-col-md5">
							<label class="layui-form-label">1码价格</label>
							<div class="layui-input-block">
							  <div class="input-group layui-col-md12">
							  <input type="text" name="price3" value="{$model.price3??''}" placeholder="请输入1码价格" class="layui-input"  verify="must">
							  <span class="input-group-addon">元</span>
							  </div>
							</div>
						</div>
						
						<div class="layui-form-item2 layui-col-md5">
							<label class="layui-form-label">杂色零售价</label>
							<div class="layui-input-block">
							  <div class="input-group layui-col-md12">
							  <input type="text" name="price1" value="{$model.price1??''}" placeholder="请输入杂色零售价" class="layui-input"  verify="must">
							  <span class="input-group-addon">元</span>
							  </div>
							</div>
						</div>
						
						<div class="layui-form-item2 layui-col-md5">
							<label class="layui-form-label">白色零售价</label>
							<div class="layui-input-block">
							  <div class="input-group layui-col-md12">
							  <input type="text" name="price2" value="{$model.price2??''}" placeholder="请输入白色零售价" class="layui-input"  verify="must">
							  <span class="input-group-addon">元</span>
							  </div>
							</div>
						</div>
						
						<div class="layui-form-item2 layui-col-md5">
							<label class="layui-form-label">杂色参考价</label>
							<div class="layui-input-block">
							  <div class="input-group layui-col-md12">
							  <input type="text" name="ckprice1" value="{$model.ckprice1??''}" placeholder="请输入杂色参考价" class="layui-input"  verify="must">
							  <span class="input-group-addon">元</span>
							  </div>
							</div>
						</div>
						
						<div class="layui-form-item2 layui-col-md5">
							<label class="layui-form-label">白色参考价</label>
							<div class="layui-input-block">
							  <div class="input-group layui-col-md12">
							  <input type="text" name="ckprice2" value="{$model.ckprice2??''}" placeholder="请输入白色参考价" class="layui-input"  verify="must">
							  <span class="input-group-addon">元</span>
							  </div>
							</div>
						</div>
												
						<div class="layui-form-item">
							<label class="layui-form-label">零售加价颜色</label>
							<div class="layui-input-block">
							  <textarea name="markup" placeholder="请输入零售加价颜色" class="layui-textarea">{$model.markup??''}</textarea>
							</div>
						</div>
						
						<div class="layui-form-item">
							<label class="layui-form-label">备注信息</label>
							<div class="layui-input-block">
							  <textarea name="remark" placeholder="备注信息仅后台可看" class="layui-textarea">{$model.remark??''}</textarea>
							</div>
						</div>
						
						<div class="layui-form-item layui-col-md3">
							<label class="layui-form-label">排序</label>
							<div class="layui-input-block">
							  <input type="text" name="sort" value="{$model.sort??1000}" placeholder="请输入排序" class="layui-input"  verify="must">
							</div>
						</div>
						
						<div class="layui-form-item">
							<label class="layui-form-label">状态</label>
							<div class="layui-input-block">
								<input type="checkbox" lay-skin="switch" value="status" lay-text="启用|禁用" {if $model.status??1 == 1} checked {/if}><input type="hidden" name="status" value="{$model.status??1}">
							</div>
						</div>
						
						<div class="layui-form-item">
							<label class="layui-form-label">小程序</label>
							<div class="layui-input-block">
								<input type="checkbox" lay-skin="switch" value="wx_isshow" lay-text="显示|隐藏" {if $model.wx_isshow??1 == 1} checked {/if}><input type="hidden" name="wx_isshow" value="{$model.wx_isshow??1}">
							</div>
						</div>
						
					</div>
					
					<div class="layui-tab-item ">
						
						<div class="layui-form-item">
							<label class="layui-form-label">供货商</label>
							<div class="layui-input-block">
							  <select name="sup_id" lay-verify="required" verify="must"'>
								<option value=""></option>
								{volist name="$supplier" id="v"}								
								{if !$action_up}
								<option value="{$v.id}">{$v.name}</option>
								{elseif $v.id == $model.sup_id}
								<option value="{$v.id}" selected="selected">{$v.name}</option>
								{else/}
								<option value="{$v.id}">{$v.name}</option>
								{/if}								
								{/volist}
							  </select>
							</div>
						</div>						

						<div class="layui-form-item">
							<label class="layui-form-label">供货编号</label>
							<div class="layui-input-block">
								<input type="hidden" name="old_onumber" value="{$model.onumber??''}">
								<input type="text" name="onumber" value="{$model.onumber??''}" placeholder="请输入供应编号" class="layui-input"  verify="must">
							</div>
						</div>
						
						<div class="layui-form-item2 layui-col-md4">
							<label class="layui-form-label">纸管重量</label>
							<div class="layui-input-block">
							  <div class="input-group layui-col-md12">
							  <input type="text" name="otube" value="{$model.otube??''}" placeholder="请输入纸管重量" class="layui-input"  verify="must">
							  <span class="input-group-addon">kg</span>
							  </div>
							</div>
						</div>
						
						<div class="layui-form-item2 layui-col-md4">
							<label class="layui-form-label">空差重量</label>
							<div class="layui-input-block">
							  <div class="input-group layui-col-md12">
							  <input type="text" name="oemptykg" value="{$model.oemptykg??''}" placeholder="请输入空差重量" class="layui-input"  verify="must">
							  <span class="input-group-addon">kg</span>
							  </div>
							</div>
						</div>
						
						<div class="layui-form-item2 layui-col-md4">
							<label class="layui-form-label">退纸管空差</label>
							<div class="layui-input-block">
							  <div class="input-group layui-col-md12">
							  <input type="text" name="rebate_kg" value="{$model.rebate_kg??''}" placeholder="退纸管和空差" class="layui-input"  verify="must">
							  <span class="input-group-addon">kg</span>
							  </div>
							</div>
						</div>
						
						<div class="layui-form-item2 layui-col-md5">
							<label class="layui-form-label">杂色进货价</label>
							<div class="layui-input-block">
								<div class="input-group layui-col-md12">
							    <input type="text" name="space1" value="{$model.space1??''}" placeholder="请输入杂色进货价" class="layui-input"  verify="must">
								<span class="input-group-addon">元</span>
								</div>
							</div>
						</div>
						
						<div class="layui-form-item2 layui-col-md5">
							<label class="layui-form-label">白色进货价</label>
							<div class="layui-input-block">
							  <div class="input-group layui-col-md12">
							  <input type="text" name="space2" value="{$model.space2??''}" placeholder="请输入白色进货价" class="layui-input"  verify="must">
							  <span class="input-group-addon">元</span>
							  </div>
							</div>
						</div>
						
						<div class="layui-form-item2 layui-col-md5">
							<label class="layui-form-label">米样进货价</label>
							<div class="layui-input-block">
							  <div class="input-group layui-col-md12">
							  <input type="text" name="space4" value="{$model.space4??'0'}" placeholder="请输入米样进货价" class="layui-input"  verify="must">
							  <span class="input-group-addon">元</span>
							  </div>
							</div>
						</div>
						
						<div class="layui-form-item2 layui-col-md5">
							<label class="layui-form-label">码样进货价</label>
							<div class="layui-input-block">
							  <div class="input-group layui-col-md12">
							  <input type="text" name="space3" value="{$model.space3??''}" placeholder="请输入码样进货价" class="layui-input"  verify="must">
							  <span class="input-group-addon">元</span>
							  </div>
							</div>
						</div>
						
						<div class="layui-form-item">
							<label class="layui-form-label">进货加价颜色</label>
							<div class="layui-input-block">
							  <textarea name="markup2" placeholder="请输入进货加价颜色" class="layui-textarea">{$model.markup2??''}</textarea>
							</div>
						</div>
					</div>
					<div class="layui-tab-item ">
						
						<div class="layui-form-item2 layui-col-md6">
							<label class="layui-form-label">阿里ID</label>
							<div class="layui-input-block">
							  <input type="text" name="alibaba_id" value="{$model.alibaba_id??''}" placeholder="请输入阿里巴巴产品id" class="layui-input">
							</div>
						</div>

						{if $action_up}
						<div class="layui-form-item2 layui-col-md6">
							<button type="button" class="pear-btn pear-btn-primary pear-btn-sm" id="pull" to_action="">
								<i class="icon pear-icon pear-icon-download"></i>
								抓取阿里巴巴数据
							</button>
						</div>
						{/if}
						
						<div class="layui-form-item">
							<label class="layui-form-label">产品标题</label>
							<div class="layui-input-block">
							  <input type="text" name="subject" value="{$model.subject??''}" placeholder="请输入产品标题" class="layui-input" >
							</div>
						</div>
						
						<div class="layui-form-item layui-img-upload layui-col-md6">
							<label class="layui-form-label">主图</label>
							<div class="layui-input-block">
								<input name="thumb" type="hidden" class="layui-input" value="{$model.thumb??''}">
								{:opt_photo("thumb")}
								<button class="pear-btn pear-btn-primary pear-btn-sm upload-image" type="button">
									<i class="icon pear-icon pear-icon-picture">
									</i>
									上传图片
								</button>
								<div class="upload-image">
									<span>
									</span>
									<img class="upload-image" src="{$model.thumb??''}">
								</div>
							</div>
						</div>
						
						<div class="layui-form-item2 layui-img-upload layui-col-md6">
							<label class="layui-form-label">轮播图1</label>
							<div class="layui-input-block">
								{:opt_photo("cover0")}
								<button class="pear-btn pear-btn-primary pear-btn-sm upload-image" type="button">
									<i class="icon pear-icon pear-icon-picture">
									</i>
									上传图片
								</button>
								<input name="cover[0]" type="hidden" class="layui-input" value="{$model.cover[0]??''}">
								<div class="upload-image">
									<span>
									</span>
									<img class="upload-image" src="{$model.cover[0]??''}">
								</div>
							</div>
						</div>
						
						<div class="layui-form-item2 layui-img-upload layui-col-md6">
							<label class="layui-form-label">轮播图2</label>
							<div class="layui-input-block">
								{:opt_photo("cover1")}
								<button class="pear-btn pear-btn-primary pear-btn-sm upload-image" type="button">
									<i class="icon pear-icon pear-icon-picture">
									</i>
									上传图片
								</button>
								<input name="cover[1]" type="hidden" class="layui-input" value="{$model.cover[1]??''}">
								<div class="upload-image">
									<span>
									</span>
									<img class="upload-image" src="{$model.cover[1]??''}">
								</div>
							</div>
						</div>
						
						<div class="layui-form-item2 layui-img-upload layui-col-md6">
							<label class="layui-form-label">轮播图3</label>
							<div class="layui-input-block">
								{:opt_photo("cover2")}
								<button class="pear-btn pear-btn-primary pear-btn-sm upload-image" type="button">
									<i class="icon pear-icon pear-icon-picture">
									</i>
									上传图片
								</button>
								<input name="cover[2]" type="hidden" class="layui-input" value="{$model.cover[2]??''}">
								<div class="upload-image">
									<span>
									</span>
									<img class="upload-image" src="{$model.cover[2]??''}">
								</div>
							</div>
						</div>
						
						<div class="layui-form-item2 layui-img-upload layui-col-md6">
							<label class="layui-form-label">轮播图4</label>
							<div class="layui-input-block">
								{:opt_photo("cover3")}
								<button class="pear-btn pear-btn-primary pear-btn-sm upload-image" type="button">
									<i class="icon pear-icon pear-icon-picture">
									</i>
									上传图片
								</button>
								<input name="cover[3]" type="hidden" class="layui-input" value="{$model.cover[3]??''}">
								<div class="upload-image">
									<span>
									</span>
									<img class="upload-image" src="{$model.cover[3]??''}">
								</div>
							</div>
						</div>
						
						<div class="layui-form-item2 layui-img-upload layui-col-md6">
							<label class="layui-form-label">轮播图5</label>
							<div class="layui-input-block">
								{:opt_photo("cover4")}
								<button class="pear-btn pear-btn-primary pear-btn-sm upload-image" type="button">
									<i class="icon pear-icon pear-icon-picture">
									</i>
									上传图片
								</button>
								<input name="cover[4]" type="hidden" class="layui-input" value="{$model.cover[4]??''}">
								<div class="upload-image">
									<span>
									</span>
									<img class="upload-image" src="{$model.cover[4]??''}">
								</div>
							</div>
						</div>
						
						<div class="layui-form-item">
							<label class="layui-form-label">面料介绍</label>
							<div class="layui-input-block">
							  <textarea id="content" name="content" class="layui-textarea">{$model.content??''}</textarea>
							</div>
						</div>
					</div>
				</div>
			</div>
        </div>
    </div>
    <div class="bottom">
        <div class="button-container">
            <button type="button" class="pear-btn pear-btn-primary pear-btn-sm" lay-submit="" verify="submit" lay-filter="save" >
                <i class="layui-icon layui-icon-ok"></i>
                提交
            </button>
            <button type="reset" class="layui-btn layui-btn-primary layui-btn-sm">
                <i class="layui-icon layui-icon-refresh"></i>
                重置
            </button>
        </div>
    </div>
</form>
<script>
    layui.use(['form', 'jquery', 'uploads','common','mycomm'], function () {
    	let form = layui.form;
    	let $ = layui.jquery;
    	let common = layui.common;
    	let mycomm = layui.mycomm;
		
		mycomm.editSubmit();
		
		{if $action_up}
		// 抓取云端数据
		$('#pull').click(function(){
			let action = $(this).attr('to_action');
			load_show('正在抓取云端数据，请稍后...');
			var url="{:U('Alibaba/pullData')}";
			var alibaba_id=$('[name="alibaba_id"]').val();
			var data={
				up:0,
				option:action,
				id:'{$model.id}',
				aid:alibaba_id,
			};
			mycomm.get(url,data,
				function(res){
					if(res.code==0){
						if(action=='' || action=='subject'){
							$('[name=subject]').val(res.data.subject);
						}
						if(action=='' || action=='content'){
							content_ueditor.ready(function() {
								content_ueditor.setContent(res.data.content);
							});
						}
						if(action=='' || action=='cover'){
							var thumb = $('[name=thumb');
							var cover0 = $('[name="cover[0]"]');
							var cover1 = $('[name="cover[1]"]');
							var cover2 = $('[name="cover[2]"]');
							var cover3 = $('[name="cover[3]"]');
							var cover4 = $('[name="cover[4]"]');
							thumb.val(res.data.cover[0]);
							cover0.val(res.data.cover[0]);
							cover1.val(res.data.cover[1]);
							cover2.val(res.data.cover[2]);
							cover3.val(res.data.cover[3]);
							cover4.val(res.data.cover[4]);
							thumb.siblings('.upload-image').children('img').attr('src',res.data.cover[0]);
							cover0.siblings('.upload-image').children('img').attr('src',res.data.cover[0]);
							cover1.siblings('.upload-image').children('img').attr('src',res.data.cover[1]);
							cover2.siblings('.upload-image').children('img').attr('src',res.data.cover[2]);
							cover3.siblings('.upload-image').children('img').attr('src',res.data.cover[3]);
							cover4.siblings('.upload-image').children('img').attr('src',res.data.cover[4]);
						}
						// if(action=='' || action=='purpose'){
						// 	var purpose=$('[name="purpose[]"]');
						// 	purpose.removeAttr('checked');
						// 	purpose.next('.layui-form-checkbox').removeClass('layui-form-checked');
						// 	purpose.each(function(){
						// 		var value=$(this).val();
						// 		for(var i=0;i<res.data.purpose.length;i++){
						// 			if(res.data.purpose[i]==value){
						// 				$(this).prop('checked',true);
						// 				$(this).next('.layui-form-checkbox').addClass('layui-form-checked');
						// 			}
						// 		}
						// 	});
						// }
						
						// if(action=='' || action=='yarn'){
						// 	$('[name="yarn"] option[value='+res.data.yarn[0]+']').attr('selected',true);
						// 	$('[name="yarn"]').next('.layui-form-select').children('.layui-select-title').children('input').val(res.data.yarn[0]);
						// }
						
						// if(action=='' || action=='link'){
						// 	var link='https://detail.1688.com/offer/'+res.data.alibaba_id+'.html';
						// 	$('[name="link"]').val(link);
						// }
					}else{
						Alert(res.msg,"error",3);
					}
				},
			);
		});
		{/if}
		
		// 自动转化出的米数
		$('[name="kgy"]').blur(function(){
			let val=$(this).val()*0.9144;
			$('[name="kgm"]').val(val.toFixed(1));
		});
		
		// 自动转化出的码数
		$('[name="kgm"]').blur(function(){
			let val=$(this).val()/0.9144;
			$('[name="kgy"]').val(val.toFixed(1));
		});
		
		// 赋值成分
		$('[component]').click(function(){
			let component=$(this).attr('component');
			$('[name="component"]').val(component);
		});
    })
</script>
{$LOAD_STYLE.bottom|raw}

{:ueditor_init()}
{:ueditor('content','100%',500)}
</body>
</html>